﻿using System;
using System.Linq;
using System.Linq.Expressions;
using MissingLinq.Linq2Management.Context;

namespace MissingLinq.Linq2Management.Test.Context
{
	internal class MockQueryProvider : IQueryProvider
	{
		#region IQueryProvider Members

		public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
		{
			Expression = expression;
			return new MockQueryable<TElement>(this, expression);
		}

		public IQueryable CreateQuery(Expression expression)
		{
			Expression = expression;
			var elementType = TypeSystem.GetElementType(expression.Type);
			return (IQueryable)Activator.CreateInstance(typeof(MockQueryable<>).MakeGenericType(elementType), new object[] { this, expression });
		}

		public TResult Execute<TResult>(Expression expression)
		{
			throw new NotImplementedException();
		}

		public object Execute(Expression expression)
		{
			throw new NotImplementedException();
		}

		#endregion

		public Expression Expression { get; private set; }
	}
}
